public class Car {
    private  String stockCode;
    private  String supplier;
    private int quantityInStock;
    private double price;
    public static int carCount = 0;
    public Car() {}
    public Car(String stockCode, String supplier, int quantity, double price) {
        if (stockCode.length() != 10) throw new IllegalArgumentException("Stock code must be 10 letters.");
        this.stockCode = stockCode;
        this.supplier = supplier;
        this.quantityInStock = quantity;
        this.price = price;
        carCount++;
    }


    public void CarItem(String stockCode,String supplier,int variable_quantity,double price){
        if (stockCode.length()!=10){
            throw new IllegalArgumentException("Stock code must be 10 characters long");
        }
        this.stockCode = stockCode;
        this.supplier = supplier;
        this.quantityInStock = variable_quantity;
        this.price = price;
    }
    public  String getStockCode(){return stockCode;}
    public String getSupplier(){return supplier;}
    public int getQuantityInStock(){return quantityInStock;}
    public double getPrice(){return price;}
    public void setStockCode(String stockCode){
        if (stockCode.length()!=10){
            throw new IllegalArgumentException("Stock code must be 10 characters long");
        }
        this.stockCode = stockCode;
    }
    public void setSupplier(String supplier){this.supplier = supplier;}
    public void setquantityInStock(int quantityInStock){this.quantityInStock = quantityInStock;}
    public void setPrice(double price) {this.price = price;}
    public void addStock(int amount){
        if ((amount < 1) ){
            System.out.println("Amount to add must be at least 1.");
        }
        if (amount > 30){
            System.out.println("Cannot exceed stock limit of 30.");
        }
    }
    public boolean sellStock(int amount){
        if(amount<1){
            System.out.println("Amount to sell must be at least 1.");
            return false;
        }
        if (amount<=quantityInStock){
            quantityInStock -= amount;
            return true;
        }
        else{
            System.out.println("Insufficient stock.");
            return false;
        }
    }
    public String getDescription(){
        return "Car Item - Supplier: " + supplier + ", Stock Code: " + stockCode;
    }
    public int getCarCount(){return carCount;}
}


